#include<stdio.h>
int main()
{
	int m = 0;

	int n = 0;

	scanf_s("%d %d", &m, &n);

	int k = (m > n ? n : m);
	while (1)
	{
		if (m % k == 0 && n % k == 0)
		{
			break;
		}
		k--;
	}

	printf("%d\n", k);
	return 0;
}